layui.use(["table", "laydate", "layer"], function () {
    var $ = layui.jquery;
    var table = layui.table;
    var layDate = layui.laydate;
    var layer = layui.layer;

    function dateModule() {
        layDate.render({
            elem: '#startDate',
            type: 'date',
            format: 'yyyyMMdd',
            trigger: 'click',
            btns: ['clear', 'now']
        });
        layDate.render({
            elem: '#endDate',
            type: 'date',
            format: 'yyyyMMdd',
            trigger: 'click',
            btns: ['clear', 'now']
        });
    }
    dateModule();

    var SmsReceiveTable = {
        tableId: "smsReceiveTable",    //表格id
        condition: {
            msisdn: "",
            startDate: "",
            endDate: ""
        }
    };

    SmsReceiveTable.initColumn = function () {
        return [[
            {field: 'msisdn', align: "center", title: 'MSISDN'},
            {field: 'receiveTime', align: "center", title: '接收时间'},
            {field: 'smsFmtName', align: "center", title: '信息格式'},
            {field: 'tpUdhiName', align: "center", title: 'GSM协议类型'},
            {field: 'content', align: "center", title: '短信内容'}
        ]];
    };

    // 渲染表格
    table.render({
        elem: '#' + SmsReceiveTable.tableId,
        url: Feng.ctxPath + '/terminalCtrl/smsReceive/list',
        height: "full-98",
        cellMinWidth: 100,
        cols: SmsReceiveTable.initColumn()
    });

    /**
     * 点击查询按钮
     */
    SmsReceiveTable.search = function () {
        var queryData = {};
        queryData['msisdn'] = $("#msisdn").val();
        queryData['startDate'] = $("#startDate").val();
        queryData['endDate'] = $("#endDate").val();
        table.reload(SmsReceiveTable.tableId, {
            where: queryData, page: {curr: 1}
        });
    };
    $("#btnSearch").click(function () {
        SmsReceiveTable.search();
    });
});
